export default {
	components: {

	},
	data() {
		return {
			inputData: {
				track: '',
				show_type: '',
				status: '',
				show_type_name: '',
				status_name: '',
			},
			waybillDetail: {},
			showType:false,
			showStatus:false,
			typeList: [
				[{
						label: "对外展示",
						id: 1
					},
					{
						label: "对内展示",
						id: 2
					},
				]
			], 
			statusList: [
				[{
						text: "已揽收",
						value: 10
					},
					{
						text: "已分拨",
						value: 50
					},
					{
						text: "已分拨",
						value: 55
					},
					{
						text: "已签收",
						value: 60
					},
				]
			], 
		}
	},
	onLoad(options) { 
		// #ifdef APP-PLUS
		var obj = JSON.parse(options.obj);
		// #endif
		
		// #ifdef MP-WEIXIN
		var obj = JSON.parse(decodeURIComponent(options.obj));
		// #endif
		this.waybillDetail = obj;
	},
	onShow() {

	},
	methods: {
		showTypeBtn(e){
			this.showType = true;
			console.log('3333')
		},
		showStatusBtn(e){
			this.showStatus = true;
		},
		typeChange(e) {
			console.log(e)
			this.showType = false;
			this.inputData.show_type = e.value[0].id;
			this.inputData.show_type_name = e.value[0].label;
			
		},
		statusChange(e) {
			this.showStatus = false; 
			this.inputData.status = e.value[0].value;
			this.inputData.status_name = e.value[0].text;
			console.log(e)
		},
		pickerChangeClose(e){
			this.showType = false;
			this.showStatus = false;
		},
		submitClick() {
			if (this.check.isNull(this.inputData.track)) {
				uni.showToast({
					title: '请填写轨迹内容',
					icon: 'error'
				});
				return;
			}
			if (this.check.isNull(this.inputData.show_type)) {
				uni.showToast({
					title: '请选择展示类型',
					icon: 'error'
				});
				return;
			}
			if (this.check.isNull(this.inputData.status)) {
				uni.showToast({
					title: '请选择状态',
					icon: 'error'
				});
				return;
			}
			uni.showModal({
				title: '确认此运单添加轨迹',
				content: '是否继续操作？',
				confirmText: '确定',
				success: res => {
					if (res.confirm) {
						this.addLogData();
					}
				}
			});
		},
		// 非平台运单手动插入轨迹
		addLogData() {
			return;
			let data = {
				waybill_id: this.waybill_id, 
				status: this.inputData.status,
				show_type: this.inputData.show_type,
				track: this.inputData.track,
			}
			if (this.$refs.loadingCover) this.$refs.loadingCover.show();
			this.http.sendRequest({
				api: this.api.order.allocationAddLog,
				data: data,
				success: res => {
					console.log(res)
					if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
					if (res.code == 1 ) {
						uni.showToast({
							title: '添加成功'
						})
						uni.navigateBack()
					}
				},
				fail: res => {
					uni.showToast({
						title: res.data
					})
					if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
				}
			});
		},
	}

}